<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="http://demo.kaidandashi.com/Public/lib/layui/css/layui.css">
		<link rel="stylesheet" type="text/css" href="http://demo.kaidandashi.com/Public/lib/Hui-iconfont/1.0.8/iconfont.css"/>
		<style type="text/css">
			body, html,#allmap {width: 98%;height: 100%;margin:1%;font-family:"微软雅黑";}
		</style>
		<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2&ak=0Qt8S1ScE8xestrsNmpYruGhz9LF2gG1"></script>
		<title>单击获取点击的经纬度</title>
	</head>
	<body>
		<div style="position:fixed;top:0;width: 100%; border-top-style: solid;border-top-width: 2px;border-top-color: #009688;z-index: 999;"></div>
		<div style="line-height:5PX;">&nbsp;</div>
		<div>
			<input type="text" class="layui-input" value="<{$zb}>" id="zuobiao" readonly="readonly" style="width: 180px;float: left;margin-left: 10px;">
			<button class="layui-btn layui-btn-radius" id="queding" style="margin-left: 10px;">
				 提交
			</button>
			<span style="float: right;margin-right: 33px;">
				<a class="layui-btn layui-btn-radius layui-btn-primary" href="javascript:location.replace(location.href);" title="刷新" style="text-decoration:none">
					 刷新
				</a>
				<button class="layui-btn layui-btn-radius layui-btn-primary" onClick="parent.layer.close(parent.layer.getFrameIndex(window.name));">
					 关闭
				</button>
			</span>
			<P style="margin:5px;">
				<!-- <label style="float: left;padding:10px;">城市：</label> -->
				<input id="txtCity" class="layui-input" type="text" value="临沂市" style="width: 200px;float: left;margin-left: 10px;display: none"/>
				<label style="float: left;padding:10px;">关键词：</label>
				<input id="txtSearch" class="layui-input" type="text" placeholder="小区、酒店、银行、景点、加油站等" style="width: 200px;float: left;margin-left: 10px;margin-right: 10px;"/>
				<span class="layui-btn layui-btn-radius layui-btn-danger" id="chazhao" style="margin-left: 10px;background-color: darkslateblue;">
					 查找
				</span>
			</P>
		</div>
		<div style="line-height:5PX;">&nbsp;</div>
		<div id="allmap"></div>
		<div style="line-height:5PX;">&nbsp;</div>
	</body>
</html>
<script type="text/javascript" src="http://demo.kaidandashi.com/Public/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://demo.kaidandashi.com/Public/lib/layer/2.4/layer.js"></script>
<script type="text/javascript">
	// 百度地图API功能
	var map = new BMap.Map("allmap");
	var isedit = "<{$isedit}>";
	var point = new BMap.Point(<{$zb}>);
	map.centerAndZoom(point,11);

	
	
	var marker = new BMap.Marker(point);  // 创建标注
	map.addOverlay(marker);               // 将标注添加到地图中
	marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
	
	//单击获取点击的经纬度
	map.addEventListener("click",function(e){
		$('#zuobiao').val(e.point.lng + "," + e.point.lat);
	});
	$('#queding').on('click', function(){
		var index = parent.layer.getFrameIndex(window.name);
		var zuobiao=$('#zuobiao').val();
		parent.$('#zuobiao').val(zuobiao);
		parent.layer.close(index);
	});
	map.addControl(new BMap.MapTypeControl());//添加地图类型控件
	map.enableScrollWheelZoom(true);//开启鼠标滚轮缩放
	map.enableInertialDragging();
	map.enableContinuousZoom();
	// 添加带有定位的导航控件
	var navigationControl = new BMap.NavigationControl({
		// 靠左上角位置
		anchor: BMAP_ANCHOR_TOP_LEFT,
		// LARGE类型
		type: BMAP_NAVIGATION_CONTROL_LARGE,
		// 启用显示定位
		enableGeolocation: true
	});
	map.addControl(navigationControl);
	// 添加定位控件
	var geolocationControl = new BMap.GeolocationControl();
	geolocationControl.addEventListener("locationSuccess", function(e){
		// 定位成功事件
		var address = '';
		address += e.addressComponent.province;
		address += e.addressComponent.city;
		address += e.addressComponent.district;
		address += e.addressComponent.street;
		address += e.addressComponent.streetNumber;
		alert("当前定位地址为：" + address);
	});
	geolocationControl.addEventListener("locationError",function(e){
		// 定位失败事件
		alert(e.message);
	});
	map.addControl(geolocationControl);
	var size = new BMap.Size(75, 20);
	map.addControl(new BMap.CityListControl({
		anchor: BMAP_ANCHOR_TOP_LEFT,
		offset: size,
		// 切换城市之间事件
		// onChangeBefore: function(){
		//    alert('before');
		// },
		// 切换城市之后事件
		// onChangeAfter:function(){
		//   alert('after');
		// }
	}));
	$(function(){
		$('#chazhao').click(function(){
			function $(sousuo){
				return document.getElementById(sousuo);
			}
			var citys=new BMap.LocalSearch(map,{renderOptions:{map:map,autoViewport:true}});
			map.clearOverlays();
			var c=$("txtCity").value;
			citys.search(c);
			var s=$("txtSearch").value;
			var local = new BMap.LocalSearch(c, {
				renderOptions:{map: map}
			});
			local.search(s);
		})
	})
	$("#tishi").click(function(){
		layer.open({
			type: 2,
			title: '',
			shadeClose: true,
			shade: false,
			maxmin: true, //开启最大化最小化按钮
			area: ['330px', '270px'],
			content: ''
		});
	})
</script>